﻿<!DOCTYPE html>
<html>
<head>
    <script src="../..//js/header.js"></script>
</head>
<body>
    <div class="data-wrap case" id="container">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
                <!--<a class="btn btn-default" data-title="新增银行卡" onclick="top.funCreatTabEvent('Tab_EditBankcard', '/view/bankcard/edit.html', '新增银行卡')"><span class="glyphicon glyphicon-plus"></span> 新增</a>-->
                <a class="btn btn-default" data-modal="/view/bankcard/edit.html" data-title="新增" data-width="452" data-height="550"><span class="glyphicon glyphicon-plus"></span> 新增</a>
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch">

                    <div class="input-group">
                        <label class="input-group-addon m5_l">银行卡号：</label>
                        <input class="form-control" name="CardNumber" type="text" />
                    </div>

                    <div class="input-group">
                        <label class="input-group-addon m5_l">银行卡用戶名：</label>
                        <input class="form-control" name="CardName" type="text" />
                    </div>

                    <div class="input-group">
                        <label class="input-group-addon m5_l">银行卡类型：</label>
                        <select class="form-control" id="CardType" name="CardType">
                            <option value="1">收款卡</option>
                            <option value="2">中转卡</option>
                            <option value="3">付款卡</option>
                        </select>
                    </div>

                    <div class="input-group">
                        <label class="input-group-addon m5_l">银行卡启用状态：</label>
                        <select class="form-control" name="EnableStatus">
                            <option value="">请选择</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>

                    <div class="input-group">
                        <label class="input-group-addon m5_l">状态：</label>
                        <select class="form-control" name="Status">
                            <option value="">请选择</option>
                            <option value="1">已分配公司</option>
                            <option value="0">未分配公司</option>
                        </select>
                    </div>

                    <button type="button" class="btn btn-default m5_l" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="paging">
        </div>

    </div>
    <script type="text/x-dot-template" id="templatePager">
        <div class="data-head table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th class="t_l">公司名称</th>
                        <th class="t_l" width="200">公司英文名称</th>
                        <th width="120">银行名称</th>
                        <th width="100">银行卡用户名</th>
                        <th width="130">银行卡号</th>
                        <th width="90">银行卡类型</th>
                        <th width="100">银行卡使用状态</th>
                        <th width="100">银行卡启用状态</th>
                        <th>收款费率</th>
                        <th class="t_l">备注</th>
                        <th width="200">操作</th>
                    </tr>
                </thead>
            </table>
        </div>

        <div class="data-body data-scroll">
            <div class="data-div-view">
                <table class="table table-hover">
                    <tbody>
                        {{~it.tData :item:index}}
                        <tr>
                            <td class="t_l">{{? item.companyResponse==null }}<span>未分配</span>{{?? }}{{= item.companyResponse.companyName }}{{? }}</td>
                            <td class="t_l" width="200">{{? item.companyResponse==null }}<span>未分配</span>{{?? }}{{= item.companyResponse.companyNameEN }}{{? }}</td>
                            <td width="120">{{= item.bankName }}</td>
                            <td width="100"><b>{{= item.cardName }}</b></td>
                            <td width="130">{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}</td>
                            <td width="90">{{= FlashPay.Util.GetCardTypeValue(item.cardType) }}</td>
                            <td width="100">{{= FlashPay.Util.GetCardStatusValue(item.usingStatus) }}</td>
                            <td width="100">{{= FlashPay.Util.GetCardEnableStatusValue(item.enableStatus) }}</td>
                            <td>{{= item.depositFeeRatio }}</td>
                            <td class="t_l">{{= item.remark }}</td>
                            <td width="200">

                                {{? item.enableStatus==1 }}
                                <a class="btn btn-warning" data-id="{{= item.bcid}}" data-status="2" cardName="{{= item.cardName}}" onclick="return changeBankCardStatus(this)">禁用</a>
                                {{?? }}
                                <a class="btn btn-success" data-id="{{= item.bcid}}" data-status="1" cardName="{{= item.cardName}}" onclick="return changeBankCardStatus(this)">启用</a>
                                {{? }}
                                {{? item.enableStatus==2 }}
                                <button type="button" class="btn btn-default" data-modal="/view/bankcard/edit.html?id={{= item.bcid}}" data-title="编辑 - {{= item.cardName }}" data-width="452" data-height="550">
                                    <span class="glyphicon glyphicon-edit"></span> 编辑
                                </button>
                                {{?}}

                                <a class="btn btn-danger m5_l" bcid="{{= item.bcid}}" enableStatus="{{=item.enableStatus}}" companyId="{{= item.companyId }}" cardName="{{= item.cardName}}" onclick="return DelBankCard(this)">
                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                </a>

                            </td>
                        </tr>
                        {{~}}
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>

    <script type="text/x-dot-template" id="templatePager3">
        <div class="data-head table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th class="t_l">公司名称</th>
                        <th class="t_l" width="200">公司英文名称</th>
                        <th width="120">银行名称</th>
                        <th width="100">银行卡用户名</th>
                        <th width="130">银行卡号</th>
                        <th width="90">银行卡类型</th>
                        <th width="100">银行卡使用状态</th>
                        <th width="100">银行卡启用状态</th>
                        <th>付款区间起迄</th>
                        <th>付款费率</th>
                        <th>跨行转账</th>
                        <th>存款等级</th>
                        <th class="t_l">备注</th>
                        <th width="200">操作</th>
                    </tr>
                </thead>
            </table>
        </div>

        <div class="data-body data-scroll">
            <div class="data-div-view">
                <table class="table table-hover">
                    <tbody>
                        {{~it.tData :item:index}}
                        <tr>
                            <td class="t_l">{{? item.companyResponse==null }}<span>未分配</span>{{?? }}{{= item.companyResponse.companyName }}{{? }}</td>
                            <td class="t_l" width="200">{{? item.companyResponse==null }}<span>未分配</span>{{?? }}{{= item.companyResponse.companyNameEN }}{{? }}</td>
                            <td width="120">{{= item.bankName }}</td>
                            <td width="100"><b>{{= item.cardName }}</b></td>
                            <td width="130">{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}</td>
                            <td width="90">{{= FlashPay.Util.GetCardTypeValue(item.cardType) }}</td>
                            <td width="100">{{= FlashPay.Util.GetCardStatusValue(item.usingStatus) }}</td>
                            <td width="100">{{= FlashPay.Util.GetCardEnableStatusValue(item.enableStatus) }}</td>
                            <td>{{= FlashPay.Util.ViewPaymentSE(item.paymentStart,item.paymentEnd) }}</td>
                            <td>{{= item.payFeeRatio }}</td>
                            <td>{{= FlashPay.Util.GetCrossBankPayValue(item.crossBankPay) }}</td>
                            <td>{{= item.depositType }}</td>
                            <td class="t_l">{{= item.remark }}</td>
                            <td width="200">

                                {{? item.enableStatus==1 }}
                                <a class="btn btn-warning" data-id="{{= item.bcid}}" data-status="2" cardName="{{= item.cardName}}" onclick="return changeBankCardStatus(this)">禁用</a>
                                {{?? }}
                                <a class="btn btn-success" data-id="{{= item.bcid}}" data-status="1" cardName="{{= item.cardName}}" onclick="return changeBankCardStatus(this)">启用</a>
                                {{? }}

                                {{? item.enableStatus==2 }}
                                <!--<button type="button" class="btn btn-default m5_l" onclick="top.funCreatTabEvent('Tab_EditBankcard{{= item.bcid}}', '/view/bankcard/edit.html?id={{= item.bcid}}', '修改銀行卡信息')">
            <span class="glyphicon glyphicon-edit"></span> 编辑
        </button>-->

                                <button type="button" class="btn btn-default" data-modal="/view/bankcard/edit.html?id={{= item.bcid}}" data-title="编辑 - {{= item.cardName }}" data-width="452" data-height="550">
                                    <span class="glyphicon glyphicon-edit"></span> 编辑
                                </button>
                                {{?}}

                                <a class="btn btn-danger m5_l" bcid="{{= item.bcid}}" enableStatus="{{=item.enableStatus}}" companyId="{{= item.companyId }}" cardName="{{= item.cardName}}" onclick="return DelBankCard(this)">
                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                </a>

                            </td>
                        </tr>
                        {{~}}
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>

    <script type="text/javascript">
        $(function () {
            doSearch();
            //搜索
            $("#btnSearch").click(function () {
                if ($("#CardType option:selected").val() == 3) {
                    doSearch3();
                }
                else {
                    doSearch();
                }
            });
        });
        function doSearch() {
            FlashPay.UI.Pager(".paging", { templateId: "templatePager", ajax: { url: '/BankCard/GetPager' } });
        }
        function doSearch3() {
            FlashPay.UI.Pager(".paging", { templateId: "templatePager3", ajax: { url: '/BankCard/GetPager' } });
        }

        //修改银行卡状态
        function changeBankCardStatus(now) {
            var Status = $(now).attr("data-status");
            var CardName = $(now).attr("cardName");
            var content = "";
            if (Status == 1) {
                content = '"' + CardName + '"' +"<br/>确定要<span class='green'>启用</span>该银行卡吗?";
            } else {
                content = '"' + CardName + '"' +"<br/>确定要<span class='red'>禁用</span>该银行卡吗?";
            }
            FlashPay.UI.Confirm({
                //content: "确定要执行吗？",
                content: content,
                ok: function () {
                    var bankCard = {};
                    var bcid = $(now).attr("data-id");
                    var enableStatus = $(now).attr("data-status");
                    bankCard.Bcid = bcid;
                    bankCard.EnableStatus = enableStatus;
                    FlashPay.Util.Ajax({
                        type: "POST",
                        url: "/BankCard/ChangeBankCardSta",
                        data: { model: bankCard },
                        success: function (data) {
                            if (!data.success) {
                                FlashPay.UI.Tip_warning(data.message == null ? "执行失败！" : data.message);
                                return;
                            } else {
                                FlashPay.UI.Tip_success(data.message == null ? "执行成功！" : data.message);
                                if ($("#CardType option:selected").val() == 3) {
                                    doSearch3();
                                }
                                else {
                                    doSearch();
                                }
                            }
                        }
                    });
                }
            });
        }

        //删除银行卡信息
        function DelBankCard(now) {
            var Bcid = $(now).attr("bcid");
            var enableStatus = $(now).attr("enableStatus");//银行卡启用状态
            var companyId = $(now).attr("companyId");//公司ID
            var CardName = $(now).attr("cardName");//银行卡用户名
            if (enableStatus != 2) {
                FlashPay.UI.Tip_danger("必须为禁用状态银行卡才允许删除！");
                return;
            }
            if (companyId != 0) {
                FlashPay.UI.Tip_danger("此银行卡下存在公司无法删除！");
                return;
            }
            FlashPay.UI.Confirm({
                content: '"'+CardName+'"'+"<br/>确定要<span class='red'>删除</span>该银行卡吗？",
                ok: function () {
                    FlashPay.Util.Ajax({
                        type: "POST",
                        url: "/BankCard/DeleteBankCard?Bcid=" + Bcid,
                        //data: JSON.stringify({ Bcid: Bcid }),
                        //dataType: "json",
                        contentType: "application/json",
                        success: function (data) {
                            if (!data.success) {
                                FlashPay.UI.Tip_warning("删除失败");
                                return;
                            } else {
                                FlashPay.UI.Tip_success("删除成功");
                                doSearch();
                            }
                        }
                    });
                }
            });
        }
    </script>
</body>
</html>